<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
<ol class="breadcrumb">
  <li><a href="<?php echo base_url('/index.php/inicio');?>">Início</a></li>
  <li><a href="<?php echo base_url('index.php/processos/consulta');?>">Processo</a></li>
  <li class="active">Info</li>
</ol>	
<!-- Nav tabs -->
<!--<ul class="nav nav-tabs" role="tablist">-->
<ul class="nav nav-pills">
  <li class="active"><a href="#processo" role="tab" data-toggle="tab">Processo</a></li>
  <li><a href="#assentamento" role="tab" data-toggle="tab">Assentamento</a></li>
  <li><a href="#audiencia" role="tab" data-toggle="tab">Audiências</a></li>
  <li><a href="#movimentacao" role="tab" data-toggle="tab">Movimentações</a></li>
  <li><a href="#historico" role="tab" data-toggle="tab">Histórico</a></li>
</ul>

<!-- Tab panes -->
<hr></hr>
<div class="tab-content">
<form class="form-horizontal">
	<div class="form-group" style="margin:0px;">
		<label class="col-sm-2 control-label">Responsável</label>
		<div class="col-sm-10" style="margin:0px;">
			<p class="form-control-static">
			<?php 
			if(!empty($nomeusuarioredist->nome_completo)){
				//echo $nomeusuario->nome_completo .' <img src="'.base_url('includes/images/r.png').'" ><span style="color:green;margin:0px;">'.$nomeusuarioredist->nome_completo.'</span>' ;
				echo $nomeusuario->nome_completo .'  =>  <span style="color:green;margin:0px;">'.$nomeusuarioredist->nome_completo.'</span>' ;
			}else{
				echo $nomeusuario->nome_completo;
			}
			
			?>
			</p>
		</div>
	</div>
	<div class="form-group" style="margin:0px;">
		<label class="col-sm-2 control-label">Número Processo</label>
		<div class="col-sm-10" style="margin:0px;">
			<p class="form-control-static">
			<?php 
				if($processo->status == '1'){ 
					echo '<span style="color:blue;margin-right:5px;">'.$processo->numeroprocesso.'</span>(<span style="color:green;margin:0px;">ATIVO</span>)';
				}else{
					echo '<span style="color:blue;margin-right:5px;">'.$processo->numeroprocesso.'</span>(<span style="color:red;margin:0px;">ARQUIVADO</span>)';
				}
			?>
			</p>
			
		</div>
	</div>
	<?php 
		if(!empty($nomeusuarioassis->nome_completo)){
	?>
		<div class="form-group" style="margin:0px;">
			<label class="col-sm-2 control-label">Assistente</label>
			<div class="col-sm-10" style="margin:0px;">
				<p class="form-control-static">
				<?php 

						echo $nomeusuarioassis->nome_completo;
					
				?>
				<a style="margin: 1px 1px 1px 1px;" href="#" onclick="remover();" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-minus"></span> Remover Assistente</a>
				</p>
				
			</div>
		</div>
	<?php
		}
	?>
</form>		
<hr></hr>
<div class="tab-pane active" id="processo">
	<br/>
	<form class="form-horizontal" role="form" id="form" method="POST">
	<input type="hidden" name="processo_id" value="<?php echo $processo_id; ?>" />
		<div class="form-group">
			<?php
				$attributes = array('class' => 'col-sm-2 control-label');
				echo form_label('Data', '', $attributes);
			?>
			<div class="col-sm-1">
			<?php 
				$data = array('disabled'=>'disabled','name'=> 'dia','id'=> 'dia','value'=>$processo->dt_processo,'placeholder'=> 'Data','class'=> 'form-control input-sm');
				echo form_input($data);
			?>
			</div>
			<div class="col-sm-2 control-label" style="text-align:left;color:red;">
			<?php echo form_error('dia');?>	
			</div>				
		</div>
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Tipo Processo</label>
		<div class="col-sm-2">
			<?php 
				echo form_dropdown('tipo_processo',$tipoprocesso,$processo->tipoprocesso_id,'class="form-control input-sm" id="tipo_processo" disabled = "disabled"');
			?>
		</div>
		<div class="col-sm-2 control-label" style="text-align:left;color:red;">
		<?php echo form_error('tipo_processo');?>	
		</div>	
		</div>
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Assunto</label>
		<div class="col-sm-3">
			<?php 
				$data = array('name'=> 'assunto','id'=> 'assunto','value'=> '','placeholder'=> 'Assunto','class'=> 'form-control input-sm');
				echo form_input($data);
			?>
		</div>
		<div class="col-sm-2 control-label" style="text-align:left;color:red;">
			<?php echo form_error('autor');?>	
		</div>	
		</div>
		<div class="form-group" id="divassunto">
		<label for="" class="col-sm-2 control-label"></label>
			<div class="col-sm-2">
			<a data-toggle="modal" href="#" class="btn btn-primary btn-xs" data-target="#myassunto"><span class="glyphicon glyphicon-plus"></span>Cadastrar Assunto</a>
			</div>
		</div>
		<div class="form-group">
			<label for="" class="col-sm-2 control-label">Numero do Processo</label>
			<div class="col-sm-2">
				<?php 
					$data = array('disabled'=>'disabled','name'=> 'numero_processo','id'=> 'numero_processo','value'=> $processo->numeroprocesso,'placeholder'=> 'Numero do Processo','class'=> 'form-control input-sm');
					echo form_input($data);
				?>
			</div>
			<div class="col-sm-2 control-label" style="text-align:left;color:red;">
				<?php echo form_error('numero_processo');?>	
			</div>	
		</div>
		<div class="form-group">
		<label id="lb_autor" class="col-sm-2 control-label">Requerente(s)</label>
		<div class="col-sm-3">
			<?php 
				$data = array('name'=> 'autor','id'=> 'autor','value'=> '','placeholder'=> 'Autor(es)','class'=> 'form-control input-sm');
				echo form_input($data);
			?>
		</div>
		<div class="col-sm-2 control-label" style="text-align:left;color:red;">
			<?php echo form_error('autor');?>	
		</div>	
		</div>
		<div class="form-group">
		<label id="lb_reu" class="col-sm-2 control-label">Requerido(s)</label>
		<div class="col-sm-3">
			<?php 
				$data = array('name'=> 'reu','id'=> 'reu','value'=> '','placeholder'=> 'Réu(s)','class'=> 'form-control input-sm');
				echo form_input($data);
			?>
		</div>
		<div class="col-sm-2 control-label" style="text-align:left;color:red;">
			<?php echo form_error('autor');?>	
		</div>	
		</div>
		<div class="form-group" id="divparte">
		<label for="" class="col-sm-2 control-label"></label>
			<div class="col-sm-2">
			<a data-toggle="modal" href="#" class="btn btn-primary btn-xs" data-target="#myModal" ><span class="glyphicon glyphicon-plus"></span>Cadastrar partes</a>
			</div>
		</div>
		
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Cód. Bic</label>
		<div class="col-sm-2">
			<?php 
				$data = array('disabled'=>'disabled','name'=> 'cod_bic','id'=> 'cod_bic','value'=>$processo->cd_bic,'placeholder'=> 'Cód. Bic','class'=> 'form-control input-sm');
				echo form_input($data);
			?>
		</div>
		</div>  
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Observação</label>
		<div class="col-sm-5">
		  
			<?php 
				$data = array('disabled'=>'disabled','name'=> 'observacao','id'=> 'observacao','placeholder'=> 'Observação','class'=> 'form-control input-sm','value'=>$processo->observacao,'rows'=>'3');
				echo form_textarea($data);
			?>
		</div>
		</div>
		<?php
		//PERMISSAO 
		if(viewPermissao(array('1','2'),$session_data)){
		?>
		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
			<?php 
				$data = array('disabled'=>'disabled','name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
				echo form_button($data);
			?>
			<a id="cancelar" href="<?php echo base_url('index.php/processos/info/'.$processo->id);?>" class="btn btn-default"></span>Cancelar</a>
			<?php if($processo->status == '1'){ ?>
				<a id="editar" href="#" class="btn btn-warning"></span>Editar</a>
			
			<?php } ?>
			</div>
		</div>
		<?php
		}
		?>
	</form>
	<div id="retorno1"></div>
</div>
<div class="tab-pane" id="assentamento">
<br/>
 <?php
//PERMISSAO
if(viewPermissao(array('1','2','3','4'),$session_data)){
?>

		<form class="form-horizontal" role="form" id="form_assentamento">
		<input type="hidden" name="processo_id" id="processo_id" value="<?php echo $processo_id; ?>" />
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Assentamento</label>
		<div class="col-sm-5">
		  <textarea class="form-control input-sm" id="observacao" name="observacao" placeholder="Assentamento" rows="3" ></textarea>
		</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
			<?php 
				$data = array('name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
				echo form_button($data);
			?>
			</div>
		</div>
		</form>
	<!--<div id="ass" style="width:auto;height:200px;overflow: auto;">-->
	<div id="ass">
		<?php 
			if(!empty($assent)){
				foreach($assent as $info){
		
		?>
				<div class="row">
					<div class="col-xs-6 col-md-1"></div>
					<div class="col-xs-12 col-sm-6 col-md-8">
					<span style="color: blue; font-size:14px;font-weight:bold;"><?php echo $info->nome_completo;?></span><br/>
					<span style="color: gray; font-size:12px;font-weight:bold;"><?php echo $info->dt_assentamento;?></span><br/><br/>
					<?php echo $info->assentamento;?>
					</div>
				</div>
				<hr></hr> 
		<?php
				}
			}else{
		?>
			<div class="row">
					<div class="col-xs-6 col-md-1"></div>
					<div class="col-xs-12 col-sm-6 col-md-8">
					<span style="color: blue; font-size:14px;font-weight:bold;"></span><br/>
					<span style="color: gray; font-size:12px;font-weight:bold;"></span><br/><br/>
					NENHUM ASSENTAMENTO ENCONTRADO
					</div>
				</div>
				<hr></hr> 
		<?php	
			} 
		
		?>
	</div>
	
<?php
}
?>
</div>
<div class="tab-pane" id="audiencia">
<br/>
	<?php
	//PERMISSAO 
	if(viewPermissao(array('1','2'),$session_data)){
	?>
	<a data-toggle="modal" href="<?php echo base_url('index.php/eventos/novomodal/'.$processo->numeroprocesso);?>" class="btn btn-primary btn-xs" data-target="#addaudiencia"><span class="glyphicon glyphicon-plus"></span>Adicionar Audiência/Perícia</a>
	<?php
	}
	?>
<br/>
<br/>
	<div id="audi_teste">
	<table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
		<thead>
			<tr>
				<th>Data/Hora</th>
				<th>Autos/RT</th>
				<th>Autor(es)</th>
				<th>Réu(s)</th>
				<th>Tipo</th>
				<th>Adv. Responsável</th>
				<th>Status</th>
				<th>Detalhes</th>
			</tr>
		</thead>
		<tbody>
			<?php
			foreach($evento as $p){
				echo "<tr>";
					echo "<td>".$p->dt_evento."</td>";
					echo "<td>".$p->numeroprocesso."</td>";
					echo "<td>".$p->autor."</td>";
					echo "<td>".$p->reu."</td>";
					echo "<td>".$p->nome_evento."</td>";
					echo "<td>".$p->nome_completo."</td>";
					echo "<td>";
					if($p->status_evento == '1'){
						echo ' <a href="#" class="btn btn-success btn-xs">ATIVO</a>';
					}elseif($p->status_evento == '2'){
						echo ' <a href="#" class="btn btn-warning btn-xs">REMARCADO</a>';
					}elseif($p->status_evento == '3'){
						echo ' <a href="#" class="btn btn-danger btn-xs">CANCELADO</a>';
					}elseif($p->status_evento == '4'){
						echo ' <a href="#" class="btn btn-info btn-xs">CONCLUÍDO</a>';
					}
					echo "</td>";
					echo '<td>';
					if($p->status_evento == '1'){
						echo '<a data-toggle="modal" href="'.base_url('index.php/eventos/info/'.$p->id).'" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span>Detalhes</a>';
					}
					echo '</td>';
				echo "</tr>";
			}
			?>
		</tbody>
    </table>
	</div>
</div>
<!-- MOVIMENTACAO -->
<div class="tab-pane" id="movimentacao">
		<?php
		//PERMISSAO 
		if(viewPermissao(array('1','2'),$session_data)){
		?>
		<form class="form-horizontal" role="form" id="form_movimentacao">
		<input type="hidden" name="processo_id" id="processo_id" value="<?php echo $processo_id; ?>" />
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Ação</label>
		<div class="col-sm-3">
		<?php 
			echo form_dropdown('tipoevento',$tipoevento,'','class="form-control input-sm" id="tipoevento"');
		?>
		</div>
		</div>
		<div id="esconde1" class="form-group" >
		<label for="" class="col-sm-2 control-label">Tipo Redistribuição</label>
		<div class="col-sm-2">
		<select id="tiporedistribuicao" name="tiporedistribuicao" class="form-control input-sm">
			<option value="1"> AUTOMÁTICO</option>
			<option value="2"> PROCURADOR GERAL</option>
		</select>
		</div>
		</div>
		<div id="esconde2" class="form-group">
		<label for="" class="col-sm-2 control-label">Data Saída</label>
		<div class="col-sm-2">
			<input type="text" name="saida" id="saida" class="form-control input-sm" >
		</div>
		</div>
		<div class="form-group">
		<label for="" class="col-sm-2 control-label">Justificativa</label>
		<div class="col-sm-5">
		  <textarea class="form-control input-sm" id="justificativa" name="justificativa" placeholder="Justificativa" rows="3" ></textarea>
		</div>
		</div>
		<div id="esconde3" class="form-group">
		<label for="" class="col-sm-2 control-label">Local</label>
		<div class="col-sm-3">
		<?php 
			echo form_dropdown('local',$local,'2','class="form-control input-sm" id="local"');
		?>
		</div>
		</div>
		<div id="esconde4" class="form-group">
		<label for="" class="col-sm-2 control-label">Advogado</label>
		<div class="col-sm-3">
		<?php 
			echo form_dropdown('usuario',$usuario,'','class="form-control input-sm" id="usuario"');
		?>
		</div>
		</div>
		<div id="esconde5" class="form-group">
		<label for="" class="col-sm-2 control-label">Senha Procurador</label>
		<div class="col-sm-2">
		  <input type="password" class="form-control input-sm" id="senha" name="senha" placeholder="Digite a senha">
		</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
			<?php 
				$data = array('name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
				echo form_button($data);
			?>
			</div>
		</div>
		</form>
		<?php
		}
		?>
</div>
<div class="tab-pane" id="historico">
<table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
      <thead>
        <tr>
          <th class="sort-column">Data Histórico</th>
          <th>Tipo</th>
          <th>Local</th>
          <th>Data Evento</th>
          <th>Responsável atual</th>
          <th>Observação</th>
        </tr>
      </thead>
      <tbody>
			<?php
				foreach($historico as $p){
					echo '<tr>';
					echo '<td>'.$p->dt_cadastro.'</td>';
					echo '<td>'.$p->nome_evento."".statusHistorico($p->status).'</td>';
					echo '<td>'.$p->nome_local.'</td>';
					echo '<td>'.$p->dt_evento.'</td>';
					echo '<td>'.$p->nome_completo.'</td>';
					echo '<td>'.$p->observacao.'</td>';
					echo '</tr>';
				}
			?>
      </tbody>
    </table>
</div>
</div>
</div>
<!-- TRAMITE Modal -->
<div class="modal bs-example-modal-lg" id="tramite" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Tramitar Processo</h4>
      </div>
      <div class="modal-body">
			<form class="form-horizontal" role="form">
				<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">Tipo</label>
				<div class="col-sm-3">
				  <input type="text" class="form-control input-sm" id="inputEmail3" placeholder="Tipo">
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Data/Hora</label>
				<div class="col-sm-3">
				  <input type="text" class="form-control input-sm" id="inputPassword3" placeholder="Data/Hora">
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Tipo</label>
				<div class="col-sm-3">
				  <input type="text" class="form-control input-sm" id="inputPassword3" placeholder="Tipo">
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Observação</label>
				<div class="col-sm-6">
				  <textarea class="form-control input-sm" id="inputPassword3" placeholder="Observação" rows="3"></textarea>
				</div>
				</div>
			</form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
        <button type="button" class="btn btn-primary">Salvar</button>
      </div>
    </div>
  </div>
</div>
<!-- FIM TRAMITE -->
<div class="modal bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">		
		<form class='form-horizontal' role='form' id='form_parte' method="POST">
            <div class="modal-header btn-primary" >
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                 <h4 class="modal-title">Cadastro Parte</h4>
            </div>
            <div class="modal-body">
				<div class="form-group">
					<label for="" class="col-sm-2 control-label">Pessoa</label>
					<div class="col-sm-3">
						<?php 
							$tipo = array(''=>'', 'F'=>'Pessoa Física','J'=>'Pessoa Jurídica');
							echo form_dropdown('tipo',$tipo,'','class="form-control" id="tipo"');
						?>
					</div>
					<div class="col-sm-2 control-label" style="text-align:left;color:red;">
					<?php echo form_error('tipo');?>	
					</div>	
				</div>
				
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">CPF/CNPJ</label>
				<div class="col-sm-3">
					<?php 
						$data = array('name'=> 'cpf_cnpj','id'=> 'cpf_cnpj','value'=> @$parte->cpfcnpj,'placeholder'=> 'CPF','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Nome</label>
				<div class="col-sm-4">
					<?php 
						$data = array('name'=> 'nome_parte','id'=> 'nome_parte','value'=> @$parte->nome_parte,'placeholder'=> 'Nome da Parte','class'=> 'form-control input-sm');
						echo form_input($data);
						
					?>
				</div>
				<div class="col-sm-2 control-label" style="text-align:left;color:red;">
				<?php echo form_error('nome_parte');?>	
				</div>	
				</div>
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Cargo</label>
				<div class="col-sm-3">
					<?php 
						$data = array('name'=> 'cargo','id'=> 'cargo','value'=> @$parte->cargo,'placeholder'=> 'Cargo','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Endereco</label>
				<div class="col-sm-5">
					<?php 
						$data = array('name'=> 'endereco','id'=> 'endereco','value'=> @$parte->endereco,'placeholder'=> 'endereco','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Cidade</label>
				<div class="col-sm-3">
					<?php 
						$data = array('name'=> 'cidade','id'=> 'cidade','value'=> @$parte->cidade,'placeholder'=> 'Cidade','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
					<label for="" class="col-sm-2 control-label">Estado</label>
					<div class="col-sm-3">
						<select class="form-control name="estado" id="estado">
							<option value="AC">Acre</option>
							<option value="AL">Alagoas</option>
							<option value="AM">Amazonas</option>
							<option value="AP">Amapá</option>
							<option value="BA">Bahia</option>
							<option value="CE">Ceará</option>
							<option value="DF">Distrito Federal</option>
							<option value="ES">Espirito Santo</option>
							<option value="GO">Goiás</option>
							<option value="MA">Maranhão</option>
							<option value="MG">Minas Gerais</option>
							<option value="MS">Mato Grosso do Sul</option>
							<option value="MT">Mato Grosso</option>
							<option value="PA">Pará</option>
							<option value="PB">Paraíba</option>
							<option value="PE">Pernambuco</option>
							<option value="PI">Piauí</option>
							<option selected value="PR">Paraná</option>
							<option value="RJ">Rio de Janeiro</option>
							<option value="RN">Rio Grande do Norte</option>
							<option value="RO">Rondônia</option>
							<option value="RR">Roraima</option>
							<option value="RS">Rio Grande do Sul</option>
							<option value="SC">Santa Catarina</option>
							<option value="SE">Sergipe</option>
							<option value="SP">São Paulo</option>
							<option value="TO">Tocantins</option>
						</select>
					</div>
					<div class="col-sm-2 control-label" style="text-align:left;color:red;">
					<?php echo form_error('tipo');?>	
					</div>	
				</div>
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Telefone</label>
				<div class="col-sm-2">
					<?php 
						$data = array('name'=> 'telefone','id'=> 'telefone','value'=> @$parte->telefone,'placeholder'=> 'Telefone','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
			
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Descrição</label>
				<div class="col-sm-4">
					<?php 
						$data = array('name'=> 'descricao','id'=> 'descricao','placeholder'=> 'Descrição','class'=> 'form-control input-sm', 'value'=> @$parte->descricao,'rows'=>'3' );
						echo form_textarea($data);
					?>
				</div>
				</div>  
				<div id="retorno"></div>
			</div>
				<div class="modal-footer">
				<?php 
					//$data = array('name'=>'salvar','type' => 'button','class' => 'btn btn-default','content' =>'Salvar','onclick'=>'');
					//echo form_button($data);
				?>
				<button type="submit" class="btn btn-primary" id="modalparte" >Salvar</button>
				<a href="#" type="button"  data-dismiss="modal" class="btn btn-default">Cancelar</a>
				</div>
		</form>
		
    </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div class="modal" id="addaudiencia">
	<div class="modal-dialog  modal-lg">
		<div class="modal-content">
		</div> 
	</div>
</div>
<div class="modal bs-example-modal-lg" id="myassunto" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">		
		<form class='form-horizontal' role='form' id='form_assunto' method="POST">
            <div class="modal-header btn-primary" >
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                 <h4 class="modal-title">Cadastro Assunto</h4>

            </div>
            <div class="modal-body">
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Nome Assunto</label>
				<div class="col-sm-5">
					<?php 
						$data = array('name'=> 'assunto','id'=> 'assunto','value'=> '','placeholder'=> 'Nome Assunto','class'=> 'form-control input-sm');
						echo form_input($data);
						
					?>
				</div>
				<div class="col-sm-2 control-label" style="text-align:left;color:red;">
				<?php echo form_error('assunto');?>	
				</div>	
				</div>
				
				
			<div id="retorno3"></div>					
			</div>
				<div class="modal-footer">
				<a href="#" type="button"  data-dismiss="modal" class="btn btn-primary">Cancelar</a>
				 <button type="submit" class="btn btn-default" id="modalassunto" >Salvar</button>
				</div>
		</form>
    </div>
        <!-- /.modal-content -->
	</div>
    <!-- /.modal-dialog -->
</div>
	<script src="<?php echo base_url('includes/js/jquery.tokeninput.js')?>"></script>
	<link href="<?php echo base_url('includes/css/token-input-facebook.css') ?>" rel="stylesheet"> 
	<script language="javascript" type="text/javascript">
		$(document).ready(function(){
			$('table.display').DataTable({
				"order": [[ 0, "asc" ]],
				"language": {
					"url": "<?php echo base_url('includes/js/Portuguese-Brasil.json'); ?>"
				},
				 "pagingType": "simple"
			});
			$("#esconde1").hide();
			$("#esconde2").hide();
			$('#esconde3').hide();
			$('#esconde4').hide();
			$('#esconde5').hide();
			$('#divparte').hide();
			
			$('#divassunto').hide();
			var form = $("#form");
			$('#editar').click(function(event) {
				$('#divparte').show();
				$('#divassunto').show();
				event.preventDefault();
				form.find(':disabled').each(function() {
					$(this).removeAttr('disabled');
				});
			});
			$("#form").validate({
				rules: {
					dia: "required",
					tipo_processo: "required",
					numero_processo: "required",
					autor: "required",
					assunto: "Campo requerido",
					reu: "required"
				},
				messages: {
					dia: "Campo requerido",
					tipo_processo: "Campo requerido",
					numero_processo: "Campo requerido",
					autor: "Campo requerido",
					assunto: "Campo requerido",
					reu: "Campo requerido"
				},
				submitHandler: function(form){
					var dados = $('#form').serialize();
					$.ajax({
						type: "POST",
						url: "<?php echo base_url('index.php/processos/editar'); ?>",
						data: dados,
						success: function( data )
						{
							$("html, body").animate({ scrollTop: $(document).height() }, "slow");
							if(data === 'OK'){
								//$('#retorno1').html('<div class="alert alert-success" role="alert">CADASTRO ATUALIZADO COM SUCESSO</div>');
								alertify.success('<div class="alert alert-success" role="alert">CADASTRO ATUALIZADO COM SUCESSO</div>');
								setTimeout(function() {
									//$('#retorno1').html('');
									window.location = "<?php echo base_url('index.php/processos/info/'.$processo->id); ?>";
								}, 2000);
							}else{
								$('#retorno1').html(data);
							}
						},
						statusCode: {
							404: function() {
								alertify.error("Pagina nao encontrada");
							}
						}
					});
					return false;
				}
			});
			$("#assunto").tokenInput("<?php echo base_url('index.php/assuntos/consultaAssuntoJson');?>", {
		        	theme: "facebook",
					prePopulate:<?php echo $assunto;?>,
					searchDelay:"50",
					tokenLimit: "1",
					preventDuplicates: "true"
					
			});
			$("#modalassunto").click(function(){
				$("#form_assunto").validate({
					rules: {
						assunto: "required"
					},
					messages: {
						assunto: "Campo requerido"
					},
					submitHandler: function(form){
						var dados = $('#form_assunto').serialize();
						$.ajax({
								type: "POST",
								url: "<?php echo base_url('index.php/assuntos/salvarModal');?>",
								data: dados,
								success: function( data )
								{
									$("html, body").animate({ scrollTop: $(document).height() }, "slow");
									if(data === 'OK'){
										$('#retorno3').html('<div class="alert alert-success" role="alert">CADASTRO EFETUADO COM SUCESSO</div>');
										setTimeout(function() {
											$('#retorno3').html('');
											$('#myassunto').modal('hide');
										}, 2000);
										$('#assunto').val('');
										
										//
									}else{
										$('#retorno3').html(data);
									}
								}
						});
						return false;
					}
				});
			});
			$("#dia").datepicker({dateFormat: "dd/mm/yy"});
			$("#numero_processo").focus();
			$('#cod_bic').attr('readonly', true);
			var tipoprocesso = "<?php echo $processo->tipoprocesso_id;?>";
			//
		
			if(tipoprocesso == 1){
				$('#cod_bic').attr('readonly', true);
				$('#lb_autor').html('Requerente(s)');
				$('#lb_reu').html('Requerido(s)');
			}else if(tipoprocesso == 2){
				$('#cod_bic').val('');
				$('#cod_bic').attr('readonly', true);
				$('#lb_autor').html('Autor(es)');
				$('#lb_reu').html('Réu(s)');
			}else{
				$('#cod_bic').attr('readonly', false);
				$('#lb_autor').html('Exequente(s)');
				$('#lb_reu').html('Executado(s)');
			}

							
			$('#tipo_processo').change( function(){
				if($(this).val() == 1){
					$('#cod_bic').attr('readonly', true);
					$('#lb_autor').html('Requerente(s)');
					$('#lb_reu').html('Requerido(s)');
				}else if($(this).val() == 2){
					$('#cod_bic').val('');
					$('#cod_bic').attr('readonly', true);
					$('#lb_autor').html('Autor(es)');
					$('#lb_reu').html('Réu(s)');
				}else{
					$('#cod_bic').attr('readonly', false);
					$('#lb_autor').html('Exequente(s)');
					$('#lb_reu').html('Executado(s)');
				}

			});
			$('#tipoevento').change( function(){
				if($(this).val() == 8){
					$('#esconde1').show();
					$('#esconde2').hide();
					$('#esconde3').hide();
					$('#esconde4').hide();
					$('#esconde5').show();
					$('#justificativa').val("");
					$('#tiporedistribuicao').val('1');
				}else if($(this).val() == 2){
					$('#esconde1').hide();
					$('#esconde2').show();
					$('#esconde3').show();
					$('#esconde4').hide();
					$('#esconde5').hide();
					$('#justificativa').val("DEVOLUÇÃO DE CARGA");
					$('#tiporedistribuicao').val('1');
				}else if($(this).val() == 1){
					$('#esconde1').hide();
					$('#esconde2').hide();
					$('#esconde3').hide();
					$('#esconde4').hide();
					$('#esconde5').hide();
					$('#tiporedistribuicao').val('1');
				}else{
					$('#esconde1').hide();
					$('#esconde2').hide();
					$('#esconde3').hide();
					$('#esconde4').hide();
					$('#esconde5').hide();
					$('#justificativa').val("");
					$('#tiporedistribuicao').val('1');
					
				}

			});
			$('#tiporedistribuicao').change( function(){
				if($(this).val() == 1){
					$('#esconde1').show();
					$('#esconde2').hide();
					$('#esconde3').hide();
					$('#esconde4').hide();
					$('#esconde5').show();
					$('#justificativa').val("");
				}else{
					$('#esconde1').show();
					$('#esconde2').hide();
					$('#esconde3').hide();
					$('#esconde4').show();
					$('#esconde5').show();
					$('#justificativa').val("");
					
				}

			});
		
			$("#autor").tokenInput("<?php echo base_url('index.php/partes/consultaPartesJson');?>", {
		        	theme: "facebook",
					prePopulate:<?php echo $autor;?>,
					searchDelay:"50",
					preventDuplicates: "true"
					
			});
		
			$("#reu").tokenInput("<?php echo base_url('index.php/partes/consultaPartesJson');?>", {
		        	theme: "facebook",
					prePopulate: <?php echo $reu;?>,
					searchDelay:"50",
					preventDuplicates: "true"
					
			});
			$("#saida").datepicker({dateFormat: "dd/mm/yy"});
			//$('#saida').datetimepicker({dateFormat: "dd/mm/yy"});
			$("#form_movimentacao").validate({
				rules: {
					tipoevento: "required",
					justificativa: "required",
					usuario: "required",
					local: "required"
				},
				messages: {
					tipoevento: "Campo requerido",
					justificativa: "Campo requerido",
					usuario: "Campo requerido",
					local: "Campo requerido"
				},
				submitHandler: function(form){
					var dados = $('#form_movimentacao').serialize();
					$.ajax({
						type: "POST",
						url: "<?php echo base_url('index.php/processos/salvarMovimentacao'); ?>",
						data: dados,
						success: function( data )
						{
							alertify.success(data);
							setTimeout(function() {
								window.location.href = "<?php echo base_url('index.php/processos/info/');?>/" + $('#processo_id').val();
							}, 2000);
							
						},
						statusCode: {
							404: function() {
								alertify.error("Pagina nao encontrada");
							}
						}
					});
					return false;
				}
			});
			$("#form_assentamento").validate({
				rules: {
					observacao: "required"
				},
				messages: {
					observacao: "Campo requerido"
				},
				submitHandler: function(form){
					var dados = $('#form_assentamento').serialize();
					$.ajax({
						type: "POST",
						url: "<?php echo base_url('index.php/processos/assentamento'); ?>",
						data: dados,
						success: function( data )
						{
							alertify.success(data);
							
							$('#ass').load('<?php echo base_url('index.php/processos/loadAssentamento'); ?>',{
								'processo_id': $("#processo_id").val()
								
								}
							);
							$("html, body").animate({ scrollTop: $(document).height() }, "slow");
						},
						statusCode: {
							404: function() {
								alertify.error("Pagina nao encontrada");
							}
						}
					});
					return false;
				}
			});
			var maskBehavior = function (val) {
				return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
			},
			options = {onKeyPress: function(val, e, field, options) {
					field.mask(maskBehavior.apply({}, arguments), options);
				}
			};
			
			$("#telefone").mask(maskBehavior, options);
			$("#modalparte").click(function(){
				$("#form_parte").validate({
					rules: {
						tipo: "required",
						nome_parte: "required",
						cpf_cnpj: "required"
					},
					messages: {
						tipo: "Campo requerido",
						nome_parte: "Campo requerido",
						cpf_cnpj: "Campo requerido"
					},
					submitHandler: function(form){
						var dados = $('#form_parte').serialize();
						$.ajax({
								type: "POST",
								url: "<?php echo base_url('index.php/partes/salvar');?>",
								data: dados,
								success: function( data )
								{
									if(data === 'OK'){
										$('#retorno').html('<div class="alert alert-success" role="alert">CADASTRO EFETUADO COM SUCESSO</div>');
										setTimeout(function() {
											$('#retorno').html('');
											$('#myModal').modal('hide');
										}, 2000);
										$('#tipo').val('');
										$('#cpf_cnpj').val('');
										$('#nome_parte').val('');
										$('#cargo').val('');
										$('#endereco').val('');
										$('#cidade').val('');
										$('#telefone').val('');
										$('#descricao').val('');
										
										//
									}else{
										$('#retorno').html(data);
									}
								}
						});
						return false;
					}
				});
			});
			
			$("#tipo").change(function(){
				 $('input[name=cpf_cnpj]').unmask();//Remove a mascara
				 if($(this).val()=="F"){//Acaso seja CPF
						$("input[name=cpf_cnpj]").mask("999.999.999-99");
						$("input[name=cpf_cnpj]").attr("placeholder","CPF");
				 } else {//Acaso seja Cnpj
						$("input[name=cpf_cnpj]").mask("99.999.999/9999-99");
						$("input[name=cpf_cnpj]").attr("placeholder","CNPJ");
				 }
			})
		});
		function remover(){
			$.ajax({
					type: "POST",
					url: "<?php echo base_url('index.php/processos/removeAssistente/'.$processo_id.'/'.$processo->usuario_id_assis);?>",
					success: function( data )
					{
						//alertify.success( data );
						window.location.href = "<?php echo base_url('index.php/processos/info/'.$processo_id); ?>";
					}
			});
			return false;
		}
	</script>
</body>
</html>
